package com.ald.crossex.dto.baidu;

/**
 * Created by lishijiong on 15/4/24.
 * 获取线路距离和时间
 */
public class BDMapRouteMatrixResponse extends BDMapBaseResponse {


    /**
     * 版权
     */
    private Info info;
    /**
     * 路径
     */
    private Elements result;

    public Info getInfo() {
        return info;
    }

    public void setInfo(Info info) {
        this.info = info;
    }

    public Elements getResult() {
        return result;
    }

    public void setResult(Elements result) {
        this.result = result;
    }


    /**
     * 返回内容转化
     *
     * @param result
     * @return
     */
    public static String routeMatrixReturnConvert(String result) {
        String s0 = result.substring(0, result.indexOf("\"elements\":[") + 12);
        String s1 = result.substring(result.indexOf("\"elements\":[") + 12, result.length() - 3);
        if (s1.contains("status")) {
            String s2[] = s1.split(",\\{\"distance");
            for (int i = 1; i < s2.length; i++) {
                s2[1] = s1.substring(s2[0].length() + 1);


            }
            for (int i = 0; i < s2.length; i++) {
                String s21 = s2[i].substring(0, s2[i].indexOf(",{\"status") - 1) + ",\"description\":" + s2[i].substring(s2[i].indexOf(",{\"status") + 1) + "}";
                s0 += s21 + ",";
            }
            s0 = s0.substring(0, s0.length() - 1) + "]}}";

        } else {
            return result;
        }
        return s0;


    }

}
